
(function(ns){

var Asset = ns.Asset = Hilo.Class.create({
    Mixes: Hilo.EventMixin,

    queue: null,
    bg: null,//背景
    ground: null,
    ready: null,
    over: null,
    numberGlyphs: null,
    birdAtlas: null,
    holdback: null,
    myPlane: null,//我的飞机
    bgfj:null,//飞机背景
    enemyPlane:null,//敌人飞机
    bullet:null,//子弹
    explosions:null,//爆炸效果
    enemyPlane1:null,
    enemyPlane2:null,
    enemyPlane3:null,
    enemyPlane_baozha1:null,//敌人飞机1
    enemyPlane_baozha2:null,//敌人飞机2
    enemyPlane_baozha3:null,//敌人飞机3
    load: function(){
        var resources = [
            {id:'bg', src:'images/bg.png'},
            {id:'ground', src:'images/ground.png'},
            {id:'ready', src:'images/ready.png'},
            {id:'over', src:'images/over.png'},
            {id:'number', src:'images/number.png'},
            {id:'bird', src:'images/bird.png'},
            {id:'holdback', src:'images/holdback.png'},
            {id:'myPlane', src:'images/my.png'},
            {id:'bgfj',src:'images/bgfj.png'},
            {id:'enemyPlane',src:'images/diren.png'},
            {id:'bullet',src:'images/zidan.png'},
            {id:'explosions',src:'images/baozha.png'},
            {id:'enemyPlane1',src:'images/enemy1.png'},//34,24
            {id:'enemyPlane2',src:'images/enemy2.png'},//46,60
            {id:'enemyPlane3',src:'images/enemy3.png'},//110,164
            {id:'enemyPlane_baozha1',src:'images/enemy1_baozha.png'},//190,34
            {id:'enemyPlane_baozha2',src:'images/enemy2_baozha.png'},//276,64
            {id:'enemyPlane_baozha3',src:'images/enemy3_baozha.png'}//1100,164
        ];

        this.queue = new Hilo.LoadQueue();
        this.queue.add(resources);
        this.queue.on('complete', this.onComplete.bind(this));
        this.queue.start();
    },

    onComplete: function(e){
        this.bg = this.queue.get('bg').content;
        this.ground = this.queue.get('ground').content;
        this.ready = this.queue.get('ready').content;
        this.over = this.queue.get('over').content;
        this.holdback = this.queue.get('holdback').content;
        this.bgfj =this.queue.get('bgfj').content;
        this.bullet =this.queue.get('bullet').content;
        this.birdAtlas = new Hilo.TextureAtlas({
            image: this.queue.get('bird').content,
            frames: [
                [0, 120, 86, 60], 
                [0, 60, 86, 60], 
                [0, 0, 86, 60]
            ],
            sprites: {
                bird: [0, 1, 2]
            }
        });
        this.myPlane = new Hilo.TextureAtlas({
            image: this.queue.get('myPlane').content,
            frames: [
            [315,0,105,124],
            [210,0,105,124],
            [105,0,105,124],
            [0,0,105,124]
            ],
            sprites: {
                myPlane: [0, 1, 2, 3]
            }
        });
        this.explosions =new Hilo.TextureAtlas({
            image:this.queue.get('explosions').content,
            frames:[
            [0,0,60,60],
            [60,0,60,60],
            [120,0,60,60],
            [180,0,60,60],
            [0,60,60,60],
            [60,60,60,60],
            [120,60,60,60],
            [180,60,60,60]
            ],
            sprites:{
                explosions:[0,1,2,3,4,5,6,7]
            }
        });
        this.enemyPlane =new Hilo.TextureAtlas({
            image:this.queue.get('enemyPlane').content,
            frames:[
            [324,0,108,124],
            [216,0,108,124],
            [108,0,108,124],
            [0,0,108,124]
            ],
            sprites:{
                enemyPlane:[0,1,2,3]
            }
        });
        this.enemyPlane1 =new Hilo.TextureAtlas({
            image:this.queue.get('enemyPlane1').content,
            frames:[
            [0,0,34,24]
            ],
            sprites:{
                enemyPlane1:[0]
            }
        });
        this.enemyPlane2 =new Hilo.TextureAtlas({
            image:this.queue.get('enemyPlane2').content,
            frames:[
            [0,0,46,60]
            ],
            sprites:{
                enemyPlane1:[0]
            }
        });
        this.enemyPlane3 =new Hilo.TextureAtlas({
            image:this.queue.get('enemyPlane3').content,
            frames:[
            [0,0,110,164]
            ],
            sprites:{
                enemyPlane1:[0]
            }
        });
        this.enemyPlane_baozha1 = new Hilo.TextureAtlas({
            image:this.queue.get('enemyPlane_baozha1').content,
            frames:[
            [0,0,38,34],
            [38,0,38,34],
            [76,0,38,34],
            [114,0,38,34],
            [152,0,38,34]
            ],
            sprites:{
                enemyPlane_baozha1:[0,1,2,3,4]
            }
        });

        var number = this.queue.get('number').content;
        this.numberGlyphs = {
            0: {image:number, rect:[0,0,60,91]},
            1: {image:number, rect:[61,0,60,91]},
            2: {image:number, rect:[121,0,60,91]},
            3: {image:number, rect:[191,0,60,91]},
            4: {image:number, rect:[261,0,60,91]},
            5: {image:number, rect:[331,0,60,91]},
            6: {image:number, rect:[401,0,60,91]},
            7: {image:number, rect:[471,0,60,91]},
            8: {image:number, rect:[541,0,60,91]},
            9: {image:number, rect:[611,0,60,91]}
        };

        this.queue.off('complete');
        this.fire('complete');
    }
});

})(window.game);